package com.animee.tally.main_frag;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.animee.tally.R;
import com.animee.tally.db.DBManager;
import com.animee.tally.db.TypeBean;
import java.util.List;
/*
 * 收入页面对应的Fragment
 */
public class IncomeFragment extends BaseFragment {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        accountBean.setsImageId(R.mipmap.in_qt_fs);
    }

    //    当前fragment获取焦点时，会调用的方法
    @Override
    public void onResume() {
        super.onResume();
//        从数据库获取收入列表类型数据集合
        List<TypeBean> incomeList = DBManager.getTypeList(1);
        typeList.clear();
        typeList.addAll(incomeList);   //添加到数据源当中
        adapter.notifyDataSetChanged();
        typeTv.setText("其他");
        typeIv.setImageResource(R.mipmap.in_qt_fs);
     }

    @Override
    public void saveAccount() {
        accountBean.setKind(1);
        DBManager.insertAccountItem(accountBean);
    }
}
